#pragma once
#include<sys/socket.h>
#include<arpa/inet.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<string>
class netAddr{
    private:
        struct sockaddr_in addr;
        std::string _ip;
        uint16_t _port;
    public:
        netAddr()=default;
        netAddr(struct sockaddr_in addr){
            this->addr=addr;
            _ip=inet_ntoa(addr.sin_addr);
            _port=ntohs(addr.sin_port);
        }
        bool operator==(const netAddr &other)const{
            return (this->addr.sin_addr.s_addr==other.addr.sin_addr.s_addr && this->addr.sin_port==other.addr.sin_port);
        }
        std::string getIp()const{return _ip;}
        uint16_t getPort()const{return _port;}
        struct sockaddr_in &getAddr(){return addr;}  
};